package com.xue.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.xue.web.service.SendMessageService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class SendMessageController {
    public JSONObject startSendLeaveMessage(HttpServletRequest req, HttpServletResponse resp){

        JSONObject jsonObject =new JSONObject();
        String message = req.getParameter("message");
        String user = (String)req.getSession().getAttribute("user");
        if (null==user||"".equals(user)){
            jsonObject.put("code",400);
            jsonObject.put("msg","你还没登录");
            return jsonObject;
        }
        if (null==message||"".equals(message)){
            jsonObject.put("code",400);
            jsonObject.put("msg","请输入留言");
            return jsonObject;
        }


        SendMessageService sendMessageService =new SendMessageService();
        jsonObject = sendMessageService.doSendMessage(user,message);

        return jsonObject;
    }
}
